package org.example;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.VBox;
import javafx.scene.web.WebEngine;
import javafx.scene.web.WebView;
import javafx.stage.Stage;

public class WebViewExample extends Application {

  @Override
  public void start(Stage primaryStage) {
    // Create a WebView control and add it to the layout
    WebView webView = new WebView();
    webView.setPrefSize(800, 600);

    VBox root = new VBox();
    root.getChildren().add(webView);

    // Create a WebEngine object for the WebView
    WebEngine webEngine = webView.getEngine();

    // Load the PDF file in an HTML page using an <embed> or <object> tag
//    String html = "<embed src=\"file:///D:/temp/temp8901664184967003568.pdf\" type=\"application/pdf\" width=\"100%\" height=\"100%\">";
//    webEngine.loadContent(html);

    String url = "file:///D:/temp/temp8901664184967003568.pdf";
    webEngine.load(url);

    // Create a scene and add it to the stage
    Scene scene = new Scene(root);
    primaryStage.setScene(scene);
    primaryStage.show();
  }

  public static void main(String[] args) {
    launch(args);
  }
}
